#include <QApplication>
#include <QMessageBox>
#include <QDebug>
#include <QSharedMemory>
#include <QLibrary>

#include <iostream>

#include "custommessagebox.h"
#include "runningselfchecking.h"


int main(int argc, char *argv[])
{    
    QApplication a(argc, argv);

    /* 获取文件路径 */
    QString projectDir = QCoreApplication::applicationDirPath();

    /* 添加字体 */
    QString filePath = projectDir + "/font/Alibaba-PuHuiTi-Regular.ttf";
    int localFont = QFontDatabase::addApplicationFont(filePath);
    qDebug() << "localFont" << localFont;
    QFontDatabase::applicationFontFamilies(localFont);
    QStringList fontFamilies = QFontDatabase::applicationFontFamilies(localFont);

    QString filePath2 = projectDir + "/font/Alibaba-PuHuiTi-Bold.ttf";
    int localFont2 = QFontDatabase::addApplicationFont(filePath2);
    qDebug() << "localFont2" << localFont2;
    QFontDatabase::applicationFontFamilies(localFont2);
    QStringList fontFamilies2 = QFontDatabase::applicationFontFamilies(localFont2);

    static QSharedMemory *singleApp = new QSharedMemory("SingleApp");//创建“SingleApp”的共享内存块
    if(!singleApp->create(1))//创建失败，说明已经有一个程序运行，
    {
        CustomMessageBox *cusMsg = new CustomMessageBox(); // 提示框
        cusMsg->show(nullptr, CMsg::CCritical, "错误", "软件已经启动");
        qApp->quit();//退出当前程序
        return -1;
    }

    RunningSelfChecking w;
    w.show();
    return a.exec();
}
